package com.ruoyi.hqfinance.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.hqfinance.domain.HqSpecialHapedPartOne;
import com.ruoyi.hqfinance.domain.HqSpecialHapedPartTwo;
import com.ruoyi.hqfinance.domain.vo.HqSpecialHapedPartVo;
import com.ruoyi.hqfinance.service.HqSpecialHapedPartService;
import com.ruoyi.logistic.domain.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/hq/specialHapedPart")
@Api(tags = "总部财务-异形件结算报表")
public class HqSpecialHapedPartController {
    @Autowired
    private HqSpecialHapedPartService hqSpecialHapedPartService;

    @ApiOperation("异形件")
    @PostMapping("/collectOne")
    public R collectOne(@RequestBody HqSpecialHapedPartVo vo){
        if (vo.getEndTime() == null || vo.getStartTime() == null || vo.getTimeType() == null){
            return R.fail("请输入查询所需的条件！");
        }
        List<HqSpecialHapedPartOne> oneList = hqSpecialHapedPartService.collectOne(vo);
        if (oneList == null || oneList.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(oneList));
        }
    }

    @ApiOperation("异形包")
    @PostMapping("/collectTwo")
    public R collectTwo(@RequestBody HqSpecialHapedPartVo vo){
        if (vo.getEndTime() == null || vo.getStartTime() == null || vo.getTimeType() == null){
            return R.fail("请输入查询所需的条件！");
        }
        List<HqSpecialHapedPartTwo> twoList = hqSpecialHapedPartService.collectTwo(vo);
        if (twoList == null || twoList.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(twoList));
        }
    }
}
